<%@ page language="java" contentType="text/html; charset=UTF-8"
		 pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://shiro.apache.org/tags" prefix="shiro" %>
<c:set var="contextPath" value="${pageContext.request.contextPath}"></c:set>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
	<title>正在进入系统...</title>
	<link rel="stylesheet" href="${contextPath}/static/statistics/css/bootstrap.min.css">
	<link rel="stylesheet" href="${contextPath}/static/statistics/css/bootstrap-datetimepicker.min.css">
</head>
<body>
<input type="hidden" value="${phone}" id="phone">
<input type="hidden" value="${url}" id="url">
<input type="hidden" value="${custCode}" id="custCode">
</body>
<script src="${contextPath}/static/statistics/js/jquery.js"></script>
<script src=${contextPath}/static/layer/layer.js></script>
<script>

	//$.get("${contextPath}/sys/user/logout");


	var phone =  document.getElementById("phone").value;
	var url = document.getElementById("url").value;
	var password = "123456";
	if (!phone) {
	    phone = "13385139176";
	    password = "13385139176";
	}else {
	    phone = "0" + phone
	}

	//layer.msg(url);
    $.post("${contextPath}/sys/user/autoLoginAuth",
		{username:phone,password:password,rememberMe:'on'},
        function(data,status){
            //console.log(data)
            if (status) {
                var jsonData = {};
                if((typeof data=='string') && data.constructor == String){
                    try {
                        jsonData = JSON.parse(data);
                    }catch (e) {
                        //console.log(e)
                    }

                }else {
                    jsonData= data
                }

                //console.log(jsonData)
                /*巧妙处理没有退出又来登陆的情况*/
                if(jsonData.success != false) {
                    //把数据存到本地存储中
                    var custCode = document.getElementById("custCode").value;
                    if(custCode){
                        localStorage.toCustomerSmokeCustCode = custCode;
                    }

                    if (url) {

                        if (url.indexOf("/") == 0 ){
                         	url =  "sys/user/home#" + url.substring(1)
						}
                        window.location.href = "${contextPath}/" + url;
					}else {
                        window.location.href = "${contextPath}/sys/user/home";
                    }
                }else {
                    layer.msg(jsonData.message)
                }
            }else {
                layer.msg("网络异常，请检查网络");
            }
        });
</script>

</html>





